package org.boticelli.plugin;

import org.boticelli.Bot;

import f00f.net.irc.martyr.InCommand;
import f00f.net.irc.martyr.replies.GenericReply;

/**
 * Implemented by all plugins.
 * <ul>
 * <li>
 * {@link #supports(Class)} method of a plugin
 * is called for every incoming message.
 * <li>
 * {@link #handle(Bot, InCommand)} is called every time
 * {@link #supports(Class)} returns <code>true</code>.
 * </li>
 * <li>
 * The {@link PluginResult} return from {@link #handle(Bot, InCommand)} decides
 * if the following plugins are called for the same message.
 * </li>
 * </ul>
 * The martyr IRC library implements a whole hierarchy of {@link InCommand} classes for the
 * different types of IRC messages.
 *
 * @author shelmberger
 */
public interface BoticelliPlugin
{
    /**
     * Returns <code>true</code> if the plugin can handle the ReplyType
     *
     * @param inCommandType     type of the incoming command
     * @return <code>true</code> if the plugin can handle the command
     */
    boolean supports(Class<? extends InCommand> inCommandType);

    /**
     * Handles incoming messages and errors.
     *
     * @param bot           the current boticelli bot   
     * @param command       the command to be handled
     * @return result of the plugin call
     */
    PluginResult handle(Bot bot, InCommand command) throws Exception;
}
